package me.chanjar.weixin.cp.bean.oa;

import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
import org.testng.annotations.Test;

import static org.testng.Assert.*;

public class WxCpOaApprovalTemplateResultTest {

  @Test
  public void testFromJson() {
    String json = "{\n"
      + "  \"errcode\": 0,\n"
      + "  \"errmsg\": \"ok\",\n"
      + "  \"template_names\": [\n"
      + "    {\n"
      + "      \"text\": \"智能印章\",\n"
      + "      \"lang\": \"zh_CN\"\n"
      + "    },\n"
      + "    {\n"
      + "      \"text\": \"Company Seal\",\n"
      + "      \"lang\": \"en\"\n"
      + "    }\n"
      + "  ],\n"
      + "  \"template_content\": {\n"
      + "    \"controls\": [\n"
      + "      {\n"
      + "        \"property\": {\n"
      + "          \"control\": \"Text\",\n"
      + "          \"id\": \"Text-1747127819114\",\n"
      + "          \"title\": [\n"
      + "            {\n"
      + "              \"text\": \"用印事由\",\n"
      + "              \"lang\": \"zh_CN\"\n"
      + "            }\n"
      + "          ],\n"
      + "          \"placeholder\": [\n"
      + "            {\n"
      + "              \"text\": \"\",\n"
      + "              \"lang\": \"zh_CN\"\n"
      + "            }\n"
      + "          ],\n"
      + "          \"require\": 1,\n"
      + "          \"un_print\": 0,\n"
      + "          \"inner_id\": \"\",\n"
      + "          \"un_replace\": 0,\n"
      + "          \"display\": 1\n"
      + "        }\n"
      + "      },\n"
      + "      {\n"
      + "        \"property\": {\n"
      + "          \"control\": \"Selector\",\n"
      + "          \"id\": \"Selector-1747123508806\",\n"
      + "          \"title\": [\n"
      + "            {\n"
      + "              \"text\": \"用印类型\",\n"
      + "              \"lang\": \"zh_CN\"\n"
      + "            }\n"
      + "          ],\n"
      + "          \"placeholder\": [\n"
      + "            {\n"
      + "              \"text\": \"\",\n"
      + "              \"lang\": \"zh_CN\"\n"
      + "            }\n"
      + "          ],\n"
      + "          \"require\": 1,\n"
      + "          \"un_print\": 0,\n"
      + "          \"inner_id\": \"\",\n"
      + "          \"un_replace\": 0,\n"
      + "          \"display\": 1\n"
      + "        },\n"
      + "        \"config\": {\n"
      + "          \"selector\": {\n"
      + "            \"type\": \"single\",\n"
      + "            \"options\": [\n"
      + "              {\n"
      + "                \"key\": \"option-1747123508806\",\n"
      + "                \"value\": [\n"
      + "                  {\n"
      + "                    \"text\": \"一般事务性用印\",\n"
      + "                    \"lang\": \"zh_CN\"\n"
      + "                  }\n"
      + "                ]\n"
      + "              },\n"
      + "              {\n"
      + "                \"key\": \"option-1747123508807\",\n"
      + "                \"value\": [\n"
      + "                  {\n"
      + "                    \"text\": \"对外事务性用印\",\n"
      + "                    \"lang\": \"zh_CN\"\n"
      + "                  }\n"
      + "                ]\n"
      + "              },\n"
      + "              {\n"
      + "                \"key\": \"option-1747123530814\",\n"
      + "                \"value\": [\n"
      + "                  {\n"
      + "                    \"text\": \"重大事务性用印\",\n"
      + "                    \"lang\": \"zh_CN\"\n"
      + "                  }\n"
      + "                ]\n"
      + "              }\n"
      + "            ],\n"
      + "            \"op_relations\": [],\n"
      + "            \"external_option\": {\n"
      + "              \"use_external_option\": false,\n"
      + "              \"external_url\": \"\"\n"
      + "            }\n"
      + "          }\n"
      + "        }\n"
      + "      },\n"
      + "      {\n"
      + "        \"property\": {\n"
      + "          \"control\": \"Tips\",\n"
      + "          \"id\": \"Tips-1747123397470\",\n"
      + "          \"title\": [\n"
      + "            {\n"
      + "              \"text\": \"说明\",\n"
      + "              \"lang\": \"zh_CN\"\n"
      + "            }\n"
      + "          ],\n"
      + "          \"placeholder\": [],\n"
      + "          \"require\": 0,\n"
      + "          \"un_print\": 0,\n"
      + "          \"inner_id\": \"\",\n"
      + "          \"un_replace\": 0,\n"
      + "          \"display\": 1\n"
      + "        },\n"
      + "        \"config\": {\n"
      + "          \"tips\": {\n"
      + "            \"tips_content\": [\n"
      + "              {\n"
      + "                \"text\": {\n"
      + "                  \"sub_text\": [\n"
      + "                    {\n"
      + "                      \"type\": 1,\n"
      + "                      \"content\": {\n"
      + "                        \"plain_text\": {\n"
      + "                          \"content\": \"用印类型说明：1. 一般事务性用印：内部日常材料流转、常规业务报表报送、非对外承诺性质的证明文件，用印文件内容不得涉及经济、法律责任条款 \"\n"
      + "                        }\n"
      + "                      }\n"
      + "                    }\n"
      + "                  ]\n"
      + "                },\n"
      + "                \"lang\": \"zh_CN\"\n"
      + "              }\n"
      + "            ]\n"
      + "          }\n"
      + "        }\n"
      + "      },\n"
      + "      {\n"
      + "        \"property\": {\n"
      + "          \"control\": \"Table\",\n"
      + "          \"id\": \"Table-1746005041962\",\n"
      + "          \"title\": [\n"
      + "            {\n"
      + "              \"text\": \"印章明细\",\n"
      + "              \"lang\": \"zh_CN\"\n"
      + "            }\n"
      + "          ],\n"
      + "          \"placeholder\": [\n"
      + "            {\n"
      + "              \"text\": \"\",\n"
      + "              \"lang\": \"zh_CN\"\n"
      + "            }\n"
      + "          ],\n"
      + "          \"require\": 0,\n"
      + "          \"un_print\": 0,\n"
      + "          \"inner_id\": \"\",\n"
      + "          \"un_replace\": 0,\n"
      + "          \"display\": 1\n"
      + "        },\n"
      + "        \"config\": {\n"
      + "          \"table\": {\n"
      + "            \"children\": [\n"
      + "              {\n"
      + "                \"property\": {\n"
      + "                  \"control\": \"Text\",\n"
      + "                  \"id\": \"Text-1747127691499\",\n"
      + "                  \"title\": [\n"
      + "                    {\n"
      + "                      \"text\": \"印章名称\",\n"
      + "                      \"lang\": \"zh_CN\"\n"
      + "                    }\n"
      + "                  ],\n"
      + "                  \"placeholder\": [\n"
      + "                    {\n"
      + "                      \"text\": \"请输入“公章”\",\n"
      + "                      \"lang\": \"zh_CN\"\n"
      + "                    }\n"
      + "                  ],\n"
      + "                  \"require\": 1,\n"
      + "                  \"un_print\": 0,\n"
      + "                  \"un_replace\": 0,\n"
      + "                  \"display\": 1\n"
      + "                }\n"
      + "              },\n"
      + "              {\n"
      + "                \"property\": {\n"
      + "                  \"control\": \"Number\",\n"
      + "                  \"id\": \"Number-1746006598992\",\n"
      + "                  \"title\": [\n"
      + "                    {\n"
      + "                      \"text\": \"普通用印\",\n"
      + "                      \"lang\": \"zh_CN\"\n"
      + "                    }\n"
      + "                  ],\n"
      + "                  \"placeholder\": [\n"
      + "                    {\n"
      + "                      \"text\": \"请填写正文用印次数\",\n"
      + "                      \"lang\": \"zh_CN\"\n"
      + "                    }\n"
      + "                  ],\n"
      + "                  \"require\": 1,\n"
      + "                  \"un_print\": 0,\n"
      + "                  \"un_replace\": 0,\n"
      + "                  \"display\": 1\n"
      + "                }\n"
      + "              },\n"
      + "              {\n"
      + "                \"property\": {\n"
      + "                  \"control\": \"Number\",\n"
      + "                  \"id\": \"Number-1746006601002\",\n"
      + "                  \"title\": [\n"
      + "                    {\n"
      + "                      \"text\": \"骑缝用印\",\n"
      + "                      \"lang\": \"zh_CN\"\n"
      + "                    }\n"
      + "                  ],\n"
      + "                  \"placeholder\": [\n"
      + "                    {\n"
      + "                      \"text\": \"请填写骑缝用印次数\",\n"
      + "                      \"lang\": \"zh_CN\"\n"
      + "                    }\n"
      + "                  ],\n"
      + "                  \"require\": 1,\n"
      + "                  \"un_print\": 0,\n"
      + "                  \"un_replace\": 0,\n"
      + "                  \"display\": 1\n"
      + "                }\n"
      + "              },\n"
      + "              {\n"
      + "                \"property\": {\n"
      + "                  \"control\": \"Selector\",\n"
      + "                  \"id\": \"Selector-1746005136537\",\n"
      + "                  \"title\": [\n"
      + "                    {\n"
      + "                      \"text\": \"是否外借\",\n"
      + "                      \"lang\": \"zh_CN\"\n"
      + "                    }\n"
      + "                  ],\n"
      + "                  \"placeholder\": [\n"
      + "                    {\n"
      + "                      \"text\": \"\",\n"
      + "                      \"lang\": \"zh_CN\"\n"
      + "                    }\n"
      + "                  ],\n"
      + "                  \"require\": 0,\n"
      + "                  \"un_print\": 0,\n"
      + "                  \"un_replace\": 0,\n"
      + "                  \"display\": 1\n"
      + "                },\n"
      + "                \"config\": {\n"
      + "                  \"selector\": {\n"
      + "                    \"type\": \"single\",\n"
      + "                    \"exp_type\": 0,\n"
      + "                    \"options\": [\n"
      + "                      {\n"
      + "                        \"key\": \"option-1746005136537\",\n"
      + "                        \"value\": [\n"
      + "                          {\n"
      + "                            \"text\": \"是\",\n"
      + "                            \"lang\": \"zh_CN\"\n"
      + "                          }\n"
      + "                        ]\n"
      + "                      },\n"
      + "                      {\n"
      + "                        \"key\": \"option-1746005136538\",\n"
      + "                        \"value\": [\n"
      + "                          {\n"
      + "                            \"text\": \"否\",\n"
      + "                            \"lang\": \"zh_CN\"\n"
      + "                          }\n"
      + "                        ]\n"
      + "                      }\n"
      + "                    ],\n"
      + "                    \"op_relations\": [],\n"
      + "                    \"external_option\": {\n"
      + "                      \"use_external_option\": false,\n"
      + "                      \"external_url\": \"\"\n"
      + "                    }\n"
      + "                  }\n"
      + "                }\n"
      + "              },\n"
      + "              {\n"
      + "                \"property\": {\n"
      + "                  \"control\": \"Date\",\n"
      + "                  \"id\": \"Date-1746005165574\",\n"
      + "                  \"title\": [\n"
      + "                    {\n"
      + "                      \"text\": \"外借开始时间\",\n"
      + "                      \"lang\": \"zh_CN\"\n"
      + "                    }\n"
      + "                  ],\n"
      + "                  \"placeholder\": [\n"
      + "                    {\n"
      + "                      \"text\": \"\",\n"
      + "                      \"lang\": \"zh_CN\"\n"
      + "                    }\n"
      + "                  ],\n"
      + "                  \"require\": 0,\n"
      + "                  \"un_print\": 0,\n"
      + "                  \"un_replace\": 0,\n"
      + "                  \"display\": 1\n"
      + "                },\n"
      + "                \"config\": {\n"
      + "                  \"date\": {\n"
      + "                    \"type\": \"day\"\n"
      + "                  }\n"
      + "                }\n"
      + "              },\n"
      + "              {\n"
      + "                \"property\": {\n"
      + "                  \"control\": \"Date\",\n"
      + "                  \"id\": \"Date-1746005173386\",\n"
      + "                  \"title\": [\n"
      + "                    {\n"
      + "                      \"text\": \"外借结束时间\",\n"
      + "                      \"lang\": \"zh_CN\"\n"
      + "                    }\n"
      + "                  ],\n"
      + "                  \"placeholder\": [\n"
      + "                    {\n"
      + "                      \"text\": \"\",\n"
      + "                      \"lang\": \"zh_CN\"\n"
      + "                    }\n"
      + "                  ],\n"
      + "                  \"require\": 0,\n"
      + "                  \"un_print\": 0,\n"
      + "                  \"un_replace\": 0,\n"
      + "                  \"display\": 1\n"
      + "                },\n"
      + "                \"config\": {\n"
      + "                  \"date\": {\n"
      + "                    \"type\": \"day\"\n"
      + "                  }\n"
      + "                }\n"
      + "              }\n"
      + "            ],\n"
      + "            \"stat_field\": [],\n"
      + "            \"sum_field\": [],\n"
      + "            \"print_format\": 0\n"
      + "          }\n"
      + "        }\n"
      + "      },\n"
      + "      {\n"
      + "        \"property\": {\n"
      + "          \"control\": \"File\",\n"
      + "          \"id\": \"item-1494250388062\",\n"
      + "          \"title\": [\n"
      + "            {\n"
      + "              \"text\": \"用印文件\",\n"
      + "              \"lang\": \"zh_CN\"\n"
      + "            },\n"
      + "            {\n"
      + "              \"text\": \"Attachment\",\n"
      + "              \"lang\": \"en\"\n"
      + "            }\n"
      + "          ],\n"
      + "          \"placeholder\": [\n"
      + "            {\n"
      + "              \"text\": \"\",\n"
      + "              \"lang\": \"zh_CN\"\n"
      + "            }\n"
      + "          ],\n"
      + "          \"require\": 1,\n"
      + "          \"un_print\": 0,\n"
      + "          \"inner_id\": \"\",\n"
      + "          \"un_replace\": 0,\n"
      + "          \"display\": 1\n"
      + "        }\n"
      + "      }\n"
      + "    ]\n"
      + "  }\n"
      + "}";

    WxCpOaApprovalTemplateResult templateDetail = WxCpGsonBuilder.create().fromJson(json, WxCpOaApprovalTemplateResult.class);
    System.out.println(templateDetail);
  }
}
